package cn.lg.soar.system.general.service;

import cn.lg.soar.core.util.InnerSerializeUtils;
import cn.lg.soar.database.base.service.IBaseService;
import cn.lg.soar.system.general.entity.UserConfig;

import java.util.Map;

/**
 * 用户配置
 * @author luguoxiang
 * @since 2023-07-13
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public interface IUserConfigService extends IBaseService<UserConfig> {

    /**
     * 获取用户配置
     * @param userId
     * @return
     */
    String get(long userId, String code);

    /**
     * 获取多个配置
     * @param codes
     * @return
     */
    Map<String, String> map(long userId, String[] codes);

    /**
     * 获取用户配置
     * @param userId
     * @return
     */
    default <T>T get(long userId, String code, Class<T> tClass) {
        return InnerSerializeUtils.parseObject(get(userId, code), tClass);
    }

    boolean set(long userId, String code, String value);

}
